import ResourceSelect from './resourceSelect'
export default {
    data() {
        return {
            targetUrl: '/resources',
            expandAll: true,
            template: {
                code: {
                    title: '代码',
                    value: ''
                },
                name: {
                    title: '名称',
                    value: ''
                },
                pid:{
                  title:'上级资源',
                  component:{
                      name:ResourceSelect
                  }
                },
                kind:{
                    title:'类型',
                    value: '',
                    component:{
                        name:'el-select',
                        options:[{label:'菜单',value:'M'},{label:'后台',value:'S'}]
                    }
                },
                path:{
                    title:'路径',
                    value: ''
                },
                icon:{
                    title:'图标',
                    value: ''
                }
            },
            columns: [{
                    title: 'ID',
                    key: 'id',
                },
                {
                    title: '代码',
                    key: 'code',
                },
                {
                    title: '名称',
                    key: 'name'
                },
                {
                    title: '类型',
                    key: 'kind',
                    formatter: function(row, column, cellValue, index) {
                      var value = row[column.property];
                      if (value == 'M') {
                        return "菜单";
                      }else if(value=='S'){
                        return "后台";
                      }else{
                          return "未定义"
                      }
                    }
                },
                {
                    title: '路径',
                    key: 'path'
                },
                {
                    title: '图标',
                    key: 'icon'
                }
            ],
            rules: {
                code: [{
                    required: true,
                    message: '请输入代码',
                    trigger: 'blur'
                }],
                name: [{
                    required: true,
                    message: '请输入名称',
                    trigger: 'blur'
                }],
            }
        }
    }
}
